Ext.define('PJ.view.registrationmanagement.ViewSignupStatusList', {
    extend: 'AM.default.DefaultList',
	alias: 'widget.re_viewSignupStatusList',
	
    initComponent: function(){
    	var me = this;
        this.columns = [{
            header: '审核状态',
            dataIndex: 'c.auditing_State',
            width: 80,
            //sortable: false,
            renderer: function(v, meta, record){
            	meta.style="padding-bottom: 0px;padding-top: 0px;line-height: 19px;padding-left: 0px;";
                var text = "",tipText="";
                if (v == 3) {
                	tipText="报名待审核";
                	text= '<div style="border-left:5px solid white;height:19px;padding-left:2px;">报名待审核</div>';
                }
                else if (v == 1) {
                	text= '<div style="border-left:5px solid green;height:19px;padding-left:2px;">报名通过</div>';
                	tipText="报名通过";
                }else if (v == 2) {
                	tipText="点击查看驳回原因";
                	text= '<div style="border-left:5px solid red;height:19px;cursor: pointer;padding-left:2px;"><span style="cursor: pointer;color:blue;">报名未通过</span></div>';
                }else if(v == 4){
                	tipText="撤销待审核";
                	text= '<div style="border-left:5px solid white;height:19px;padding-left:2px;">撤销待审核</div>';
                }else if(v == 5){
                	tipText="报名通过(撤销未通过)";
                	text= '<div style="border-left:5px solid green;height:19px;padding-left:2px;">报名通过(<span style="cursor: pointer;color:blue;">撤销未通过</span>)</div>';
                }
                meta.tdAttr = 'data-qtip="' + tipText + '" auditStatus=' + record.get("c.auditing_State") + ' classUserId=' + record.get("classUserId") + ' userId=' + record.get("userId");
                return text;
            },
    		listeners: {
    			click: function(g, clm){
//    				var userId = clm.getAttribute("userId");
    				var auditStatus = clm.getAttribute("auditStatus");
    				var classUserId = clm.getAttribute("classUserId");
    				if(auditStatus == 5){
    					var win = Ext.create('PJ.view.registrationmanagement.CheckEdit', {
        					title: "查看驳回原因",
        					flag:4,
        					grid: me,
        					isDisable:false,
        					isReadOnly:true
        				}).show();
        				var actionName = "load";
        				if(gj_onlineLearning_constant.loadType == "jsonp"){
        					actionName = "loadJsonp";
        				}
        				win.down("form").getForm().doAction(actionName,{
        					url:me.store.findRejectReasonUrl,
        					params:{
        						classUserId: classUserId
        					},
        					success:function(f,action){
        					}
        				});
    				}else if(auditStatus == 2){
    					var win = Ext.create('PJ.view.trainingmanagement.CheckEdit', {
        					title: "查看驳回原因",
        					flag:4,
        					grid: me,
        					isDisable:false,
        					isReadOnly:true
        				}).show();
        				var actionName = "load";
        				if(gj_onlineLearning_constant.loadType == "jsonp"){
        					actionName = "loadJsonp";
        				}
        				win.down("form").getForm().doAction(actionName,{
        					url:me.store.findCommentUrl,
        					params:{
        						classUserId: classUserId
        					},
        					success:function(f,action){
        					}
        				});
    				}else{
    					return;
    				}
    			}
    		}
        },{
        	header: '学员帐号',
        	dataIndex: 'bu.login_id',
        	width: 80
        },{
        	header: '姓名',
        	dataIndex: 'bu.user_Name',
        	width: 80
        }, {
            header: '性别',
            dataIndex: 'bb.order_num',
            width: 45
        },{
            header: '出生年月',
            dataIndex: 'c.birthday',
            width: 70,
            renderer: function(value, meta, record){
                meta.tdAttr = 'data-qtip="' + value + '"';
                return value;
            }
        }, {
            header: '民族',
            dataIndex: 'bt.order_num',
            width: 80,
            renderer: function(value, meta, record){
                meta.tdAttr = 'data-qtip="' + value + '"';
                return value;
            }
        }, {
            header: '单位',
            dataIndex: 'd.depname',
            flex:.8,
            renderer: function(value, meta, record){
                meta.tdAttr = 'data-qtip="' + value + '"';
                return value;
            }
        },{
            header: '手机号',
            dataIndex: 'c.mobile_Telephone',
            width: 100
        },{
            header: '职级',
            dataIndex: 'bbb.order_num',
            width: 135,
            renderer: function(value, meta, record){
                meta.tdAttr = 'data-qtip="' + value + '"';
                return value;
            }
        }, {
            header: '单位及职务',
            dataIndex: 'c.duty_remark',
            flex:1,
            renderer: function(value, meta, record){
                meta.tdAttr = 'data-qtip="' + value + '"';
                return value;
            }
        },/* {
            header: '联系电话',
            dataIndex: 't.mobileTelephone',
            width: 90,
            renderer: function(value, meta, record){
                meta.tdAttr = 'data-qtip="' + value + '"';
                return value;
            }
        },*/ {
            header: '备注',
            dataIndex: 'c.remark',
            flex:.5,
            renderer: function(value, meta, record){
                meta.tdAttr = 'data-qtip="' + value + '"';
                return value;
            }
        },{
            header: '学时',
            dataIndex: 'trainingHour',
            sortable: false,
            width:60
        },{
        	header: '考核状态',
            dataIndex: 'examinationResult',
            sortable: false,
            width:60
        }];
        this.store = Ext.create('PJ.'+prototype+'.unitregistrationmanagement.ViewSignupStatusList', {
            isLoad: false
        });
        this.loadType = gj_onlineLearning_constant.loadType;
        this.callParent(arguments);
    },
    //导出
    onExportClick: function(){
    	var me = this;
    	var store = me.getStore();
    	var params=store.proxy.extraParams;
    	var href=store.exportUrl + "?searchClassIds=" + me.up('window').classId;
    	
    	for(var param in params){
    		if(params[param] === undefined){
    			href+="&"+param+"=";
    		}else{
    			if(param=="searchClassID"){
    				href+="&"+param+"="+params[param];
    			}else if(param=="clickSource"){
    				href+="&"+param+"="+params[param];
    			}
    		}
    	}
    	href+="&searchSignUpState=1&searchSignUpState=5";
    	href = encodeURI(href);
    	var atag = Ext.get("exportResume");
    	atag.set({
    		"href": href
    	});
    	atag.dom.click();
    },
    listeners: {
    	selectionchange: function(selModel, selected){
    		this.down('#' + this.oldId + 'Export').setDisabled(selected.length === 0);
    	},
    	viewready: function(){
    		this.addDocked([{
                dock: 'top',
                xtype: "searchform",
    			columnCount: 2,
    			collapsedFieldSet: false,
                fieldDefaults: {
                    xtype: "textfield",
                    labelAlign: 'right',
                    labelWidth: 80
                },
                items: [{
                    fieldLabel: '学员帐号',
                    name: "searchLoginID",
                    emptyText: "请输入学员帐号",
                    columnWidth:.3,
                }, {
                    fieldLabel: "姓名",
                    name: "searchUserName",
                    emptyText: "请输入姓名",
                    columnWidth:.3,
                },{
                    fieldLabel: '单位',
                    name: "searchDepName",
                    emptyText: "请输入单位",
        			columnWidth: .4,
                },/*,{
					xtype: "combo",
					fieldLabel: '审核状态',
					name: "auditingState",
					store: Ext.create("Ext.data.ArrayStore", {
						fields: ['value', 'text'],
						data: [[1, '审核通过'],[2,'未审核通过'],[3,'未审核']]
					}),
					valueField: 'value',
					displayField: 'text',
					editable: false,
					emptyText: "请选择"
				}*/],
    			onResetClick: function(button){
                    var form = button.up('form');
                    var gridPanel = form.grid;
                    var newParams = {
            				searchClassID: gridPanel.up('window').classId,
            				clickSource:this.up('window').clickSource,
            				auditingState: 1
                    };
                    gridPanel.getStore().proxy.extraParams = {};
                    var params = gridPanel.getStore().proxy.extraParams;
                    Ext.apply(params, newParams);
                    form.getForm().reset();
                },
                grid: this
            },{
                xtype: 'toolbar',
                dock: 'top',
                displayInfo: true,
                items: [{
                    text: '导出',
                    iconCls: 'deriveIco',
                    itemId: this.oldId + "Export",
                    disabled: false,
                    scope: this,
                    handler: this.onExportClick
                }]
            }]);
    		// 触发权限过滤事件
    		this.fireEvent("permission", this);
    		var params = this.store.proxy.extraParams;
    		var newParams = {
    				searchClassID: this.up('window').classId,
    				clickSource:this.up('window').clickSource,
    				searchSignUpState:this.up('window').auditingState,
    				auditingState: 1
    		};
    		Ext.apply(params, newParams);
    		this.store.isLoad = true;
    		this.store.load();
    	}
    }
});
